import {
  createUserRes,
  ICreateUser,
  IUserDetailUpdate,
  IUserLogin,
  userDetail,
  userLoginRes
} from './types'
import gcRequest from '..'

export const createUser = (data: ICreateUser) => {
  return gcRequest.post<createUserRes.RootObject>({
    url: '/user',
    data
  })
}

export const userLogin = (data: IUserLogin) => {
  return gcRequest.post<userLoginRes.RootObject>({
    url: '/auth/login',
    data
  })
}

export const getUser = (id: number) => {
  return gcRequest.get<userDetail.RootObject>({
    url: `/user/${id}`
  })
}

export const updateUserDetail = (id: number, user: IUserDetailUpdate) => {
  return gcRequest.patch<createUserRes.RootObject>({
    url: `/user/${id}`,
    data: user
  })
}
